<h3>数据库对象</h3>
<p>
    <code>$GLOBAL['obj_db']</code> 是系统中的一个全局对象，您可以在任何地方使用这个对象。该对象的类文件位于 <code>./bg_core/class/database.class.php</code>，更为详细的使用可以参考该文件的源代码。
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="attr"></a>
<h3>属性</h3>
<hr>
<div>&nbsp;</div>

<div class="table-responsive">
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>属性</th>
                <th>类型</th>
                <th>说明</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>obj_mysqli</td>
                <td>object</td>
                <td>MySQLi 对象，详情请查看 <a href="http://www.php.net/manual/zh/book.mysqli.php" target="_blank">PHP 官方网站</a>。</td>
            </tr>
            <tr>
                <td>obj_result</td>
                <td>object</td>
                <td>mysqli_result 对象，详情请查看 <a href="http://www.php.net/manual/zh/class.mysqli-result.php" target="_blank">PHP 官方网站</a>。</td>
            </tr>
            <tr>
                <td>db_host</td>
                <td>string</td>
                <td>数据库服务器地址</td>
            </tr>
            <tr>
                <td>db_port</td>
                <td>string</td>
                <td>数据库服务器端口</td>
            </tr>
            <tr>
                <td>db_name</td>
                <td>string</td>
                <td>数据库名称</td>
            </tr>
            <tr>
                <td>db_user</td>
                <td>string</td>
                <td>数据库用户名</td>
            </tr>
            <tr>
                <td>db_pass</td>
                <td>string</td>
                <td>数据库密码</td>
            </tr>
            <tr>
                <td>db_charset</td>
                <td>string</td>
                <td>数据库编码，一般为 <mark>utf8</mark>，请按照服务器提供商所提供的资料填写。</td>
            </tr>
            <tr>
                <td>db_debug</td>
                <td>bool</td>
                <td>是否开启数据库 debug 模式</td>
            </tr>
        </tbody>
    </table>
</div>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="method"></a>
<h3>方法</h3>
<hr>
<div>&nbsp;</div>

<div class="table-responsive">
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>方法</th>
                <th>说明</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><a href="#query">query</a></td>
                <td>对数据库执行一次查询</td>
            </tr>
            <tr>
                <td><a href="#create_table">create_table</a></td>
                <td>创建一个数据表</td>
            </tr>
            <tr>
                <td><a href="#create_index">create_index</a></td>
                <td>创建一个索引</td>
            </tr>
            <tr>
                <td><a href="#create_view">create_view</a></td>
                <td>创建一个视图</td>
            </tr>
            <tr>
                <td><a href="#copy_table">copy_table</a></td>
                <td>复制一个表格</td>
            </tr>
            <tr>
                <td><a href="#alter_table">alter_table</a></td>
                <td>改变一个表格</td>
            </tr>
            <tr>
                <td><a href="#insert">insert</a></td>
                <td>插入一条记录</td>
            </tr>
            <tr>
                <td><a href="#update">update</a></td>
                <td>更新记录</td>
            </tr>
            <tr>
                <td><a href="#delete">delete</a></td>
                <td>删除记录</td>
            </tr>
            <tr>
                <td><a href="#count">count</a></td>
                <td>统计记录</td>
            </tr>
            <tr>
                <td><a href="#select">select</a></td>
                <td>读取记录</td>
            </tr>
            <tr>
                <td><a href="#duplicate">duplicate</a></td>
                <td>克隆一条记录</td>
            </tr>
        </tbody>
    </table>
</div>

<div>&nbsp;</div>
<a name="query"></a>
<h4><code>query($sql)</code></h4>

<p class="text-info">说明</p>
<p>对数据库执行一次查询。</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">sql</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>钩子的名称，详情请查看 <a href="{$BG_URL_HELP}index.php?m=plugin&a=hook">钩子列表</a>。</td>
                </tr>
            </tbody>
        </table>
    </div>

<h4>返回</h4>
<p>失败时返回 FALSE，成功执行 SELECT, SHOW, DESCRIBE 或 EXPLAIN 查询会返回一个 mysqli_result 对象，其他查询则返回 TRUE。</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="create_table"></a>
<h4><code>create_table($table, $data, $primary[, $comment = ''[, $engine = 'InnoDB']])</code></h4>

<p class="text-info">说明</p>
<p>
    创建一个数据表
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">primary</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>主键</td>
                </tr>
                <tr>
                    <td class="text-nowrap">comment</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>备注</td>
                </tr>
                <tr>
                    <td class="text-nowrap">engine</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>数据引擎，默认为 InnoDB。</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        请查看 <a href="#query">query</a>。
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleCreat = array(
    //'字段名'    =&gt; '字段结构',
    'article_id'    =&gt; 'int NOT NULL AUTO_INCREMENT COMMENT "ID"',
    'article_title' =&gt; 'varchar(300) NOT NULL COMMENT "标题"',
    'article_link'  =&gt; 'varchar(900) NOT NULL COMMENT "链接"',
    'article_time'  =&gt; 'int NOT NULL COMMENT "记录时间"'
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="create_index"></a>
<h4><code>create_index($index, $table, $data[, $type = 'BTREE'[, $drop_overlap = false]])</code></h4>

<p class="text-info">说明</p>
<p>
    创建一个索引
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">index</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>索引的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>索引结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">type</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>索引类型，默认为 BTREE。</td>
                </tr>
                <tr>
                    <td class="text-nowrap">drop_overlap</td>
                    <td class="text-nowrap">bool</td>
                    <td class="text-nowrap">false</td>
                    <td>是否丢弃重名的索引，当该参数为 true 时，将丢弃重名的索引，默认为 false。</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        请查看 <a href="#query">query</a>。
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleIndex = array(
    //'字段名',
    'article_top',
    'article_time_pub',
    'article_id',
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="create_view"></a>
<h4><code>create_view($view, $data, $table, $join)</code></h4>

<p class="text-info">说明</p>
<p>
    创建一个视图
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">view</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>视图的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>视图结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">join</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>连接条件</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        请查看 <a href="#query">query</a>。
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$viewCreat = array(
    //array('字段名', '表名'),
    array('tag_id', 'tag'),
    array('tag_name', 'tag'),
    array('tag_status', 'tag'),
    array('tag_article_count', 'tag'),
    array('belong_article_id', 'tag_belong'),
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>join</code> 示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$join = 'LEFT JOIN `tag_belong` ON (`tag`.`tag_id`=`tag_belong`.`belong_tag_id`)';</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="copy_table"></a>
<h4><code>copy_table($table, $table_src, $data, $primary[, $comment = ''[, $engine = 'InnoDB']])</code></h4>

<p class="text-info">说明</p>
<p>
    复制一个表格
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">table_src</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>源数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>表格结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">primary</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>主键</td>
                </tr>
                <tr>
                    <td class="text-nowrap">comment</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>备注</td>
                </tr>
                <tr>
                    <td class="text-nowrap">engine</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>数据引擎，默认为 InnoDB。</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        请查看 <a href="#query">query</a>。
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleCreat = array(
    array(
        'src'       =&gt; 'article_id', //源字段
        'target'    =&gt; 'article_id', //目标字段, 如同名可省略
        'create'    =&gt; 'int NOT NULL AUTO_INCREMENT COMMENT "ID"', //字段结构
    ),
    array(
        'src'       =&gt; 'article_content',
        'target'    =&gt; 'article_content',
        'create'    =&gt; 'text NOT NULL COMMENT "内容"',
    ),
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="alter_table"></a>
<h4><code>alter_table($table[, $data = false[, $rename = false]])</code></h4>

<p class="text-info">说明</p>
<p>
    改变一个表格
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap" rowspan="2">
                        false 至少选择一个
                    </td>
                    <td>表格结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">rename</td>
                    <td class="text-nowrap">string</td>
                    <td>重命名</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        请查看 <a href="#query">query</a>。
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleAlter = array(
    'article_upfile_id' =&gt; array( //'字段名'
        'CHANGE',//动作, 可选 ADD (添加)、DROP (丢弃)、CHANGE (变更)、ADD PRIMARY KEY (添加主键)、DROP PRIMARY KEY (丢弃主键)
        'int NOT NULL COMMENT "附件ID"', //字段结构
        'article_attach_id' //新字段名, 动作为 CHANGE 时必需
    ),
    'article_upfile_id' =&gt; array(
        'CHANGE',
        'int NOT NULL COMMENT "附件ID"',
        'article_attach_id'
    ),
    'article_cate_id' =&gt; array(
        'CHANGE',
        'smallint NOT NULL COMMENT "隶属栏目ID"',
        'article_cate_id'
    ),
    'article_mark_id' =&gt; array(
        'CHANGE',
        'smallint NOT NULL COMMENT "标记ID"',
        'article_mark_id'
    ),
    'article_time_day' =&gt; array(
        'ADD',
        'tinyint NOT NULL COMMENT "日点重置时间"',
    )
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="insert"></a>
<h4><code>insert($table, $data[, $field = false])</code></h4>

<p class="text-info">说明</p>
<p>
    插入一条记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>数据结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">field</td>
                    <td class="text-nowrap">bool</td>
                    <td class="text-nowrap">false</td>
                    <td>值是否为字段名</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        记录 ID
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleData = array(
    //'字段名'     =&gt; '值',
    'article_title'     =&gt; '文章标题',
    'article_content'   =&gt; '文章内容'
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="update"></a>
<h4><code>update($table, $data[, $where = ''[, $field = false]])</code></h4>

<p class="text-info">说明</p>
<p>
    更新记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>数据结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">where</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 WHERE 条件</td>
                </tr>
                <tr>
                    <td class="text-nowrap">field</td>
                    <td class="text-nowrap">bool</td>
                    <td class="text-nowrap">false</td>
                    <td>值是否为字段名</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        影响的记录条数
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleData = array(
    //'字段名'     =&gt; '值',
    'article_title'     =&gt; '文章标题',
    'article_content'   =&gt; '文章内容'
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>where</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$where = '`article_id`=1';</code></pre>
</p>


<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="delete"></a>
<h4><code>delete($table, $where)</code></h4>

<p class="text-info">说明</p>
<p>
    删除记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">where</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>SQL 语句中的 WHERE 条件</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        删除的记录条数
    </p>

<div>&nbsp;</div>
<h5><code>where</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$where = '`article_id`=1';</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="count"></a>
<h4><code>count($table[, $where = ''[, $distinct = '']])</code></h4>

<p class="text-info">说明</p>
<p>
    统计记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">where</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 WHERE 条件</td>
                </tr>
                <tr>
                    <td class="text-nowrap">distinct</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">false</td>
                    <td>不重复的条件</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        记录条数
    </p>

<div>&nbsp;</div>
<h5><code>where</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$where = '`article_cate_id`=1';</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>distinct</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$distinct = array(
    //'字段名',
    'article_id',
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="select"></a>
<h4><code>select($table[, $data = ''[, $where = ''[, $group = ''[, $order = ''[, $length = 0[, $start = 0[, $field = false]]]]]]])</code></h4>

<p class="text-info">说明</p>
<p>
    读取记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>数据结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">where</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 WHERE 条件</td>
                </tr>
                <tr>
                    <td class="text-nowrap">group</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 GROUP 条件</td>
                </tr>
                <tr>
                    <td class="text-nowrap">order</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 ORDER 条件</td>
                </tr>
                <tr>
                    <td class="text-nowrap">length</td>
                    <td class="text-nowrap">int</td>
                    <td class="text-nowrap">false</td>
                    <td>读取记录条数</td>
                </tr>
                <tr>
                    <td class="text-nowrap">start</td>
                    <td class="text-nowrap">int</td>
                    <td class="text-nowrap">false</td>
                    <td>从第几条记录开始读取</td>
                </tr>
                <tr>
                    <td class="text-nowrap">field</td>
                    <td class="text-nowrap">bool</td>
                    <td class="text-nowrap">false</td>
                    <td>data 结构是否已经为字段名，值为 false 时，将自动给字段名加上 <kbd>`</kbd> 符号。</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        记录条数
    </p>

<div>&nbsp;</div>
<h5><code>data</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleData = array(
    //'字段名'     =&gt; '值',
    'article_title'     =&gt; '文章标题',
    'article_content'   =&gt; '文章内容'
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>where</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$where = '`article_cate_id`=1';</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>group</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$group = array(
    //字段名,
    'article_top',
    'article_time_pub',
    'article_id'
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>order</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$order = array(
    array(
        'article_top', //字段名
        'DESC' //排序方式，可选 ASC (递增)、DESC (递减)
    ),
    array(
        'article_time_pub',
        'DESC'
    ),
    array(
        'article_id',
        'DESC'
    )
);</code></pre>
</p>

<div>&nbsp;</div>
<div class="text-right">
    <a href="#top">
        <span class="oi oi-chevron-top"></span>
        top
    </a>
</div>
<hr>
<div>&nbsp;</div>

<a name="duplicate"></a>
<h4><code>duplicate($table_dst, $data_dst, $table_src, $data_src[, $where = ''])</code></h4>

<p class="text-info">说明</p>
<p>
    克隆一条记录
</p>

    <h4>参数</h4>
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th class="text-nowrap">名称</th>
                    <th class="text-nowrap">类型</th>
                    <th class="text-nowrap">必需</th>
                    <th>描述</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="text-nowrap">table_dst</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>目标数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data_dst</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>目标数据结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">table_src</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">true</td>
                    <td>源数据表的名称</td>
                </tr>
                <tr>
                    <td class="text-nowrap">data_src</td>
                    <td class="text-nowrap">array</td>
                    <td class="text-nowrap">true</td>
                    <td>源数据结构</td>
                </tr>
                <tr>
                    <td class="text-nowrap">where</td>
                    <td class="text-nowrap">string</td>
                    <td class="text-nowrap">false</td>
                    <td>SQL 语句中的 WHERE 条件</td>
                </tr>
            </tbody>
        </table>
    </div>

<div>&nbsp;</div>

    <h4>返回结果</h4>
    <p>
        新记录 ID
    </p>

<div>&nbsp;</div>
<h5><code>data_dst</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleData = array(
    //'字段名'     =&gt; '值',
    'article_title'     =&gt; '文章标题',
    'article_content'   =&gt; '文章内容'
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>data_src</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$articleData = array(
    //'字段名'     =&gt; '值',
    'article_title'     =&gt; '文章标题',
    'article_content'   =&gt; '文章内容'
);</code></pre>
</p>

<div>&nbsp;</div>
<h5><code>where</code> 结构示例</h5>
<p>
<pre class="border rounded"><code class="language-php">$where = '`article_cate_id`=1';</code></pre>
</p>
